package qdu.testsocket2;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.Socket;

public class TestSocketClient {
    public static void main(String[] args) {
        Socket s = null;
        try {
            s = new Socket("192.168.47.99", 9999);
            BufferedWriter bw = new BufferedWriter(
                new OutputStreamWriter(s.getOutputStream())
            );
            bw.write("hello server");
            bw.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally{
            try {
                if(s != null)
                    s.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
/*     //通过标准输入构造Scanner对象
    Scanner scanner = new Scanner(System.in);

    //读取一个段文本，空格符截止
    System.out.print(scanner.next());//输入 abc def 输出 abc

    //读取一行文本，换行符截止
    System.out.print(scanner.nextLine());//输入 abc def 输出 abc def */